package Sort;

public class 冒泡排序 {

    public static void bubbleSort(int[] array) {
        long start = System.currentTimeMillis();
        int n = array.length;
        if (n <= 1)
            return;
        for (int i = 0; i < n; i++) {
            boolean flag = false;
            for (int j = 0; j < n - i - 1; j++) {
                flag = true;
                if (array[j] > array[j + 1]) {
                    int tmp = array[j];
                    array[j] = array[j + 1];
                    array[j + 1] = tmp;
                }
            }
            if (!flag) {
                break;
            }
        }
        long end = System.currentTimeMillis();
        System.out.println("冒泡排序耗时" + (end - start)+"ms");

    }
}
